package com.knife.blog.logic.impl;

import java.util.List;

import com.knife.blog.domain.BlogInfo;
import com.knife.blog.domain.VisitInfo;
import com.knife.blog.logic.BlogVisitorService;
import com.knife.web.tools.DbPageList;
import com.knife.web.tools.IPageList;

public class BlogVisitorServiceImpl extends DAOSupportService implements BlogVisitorService {

	public IPageList queryVisitInfo(BlogInfo blog,int currentPage, int pageSize) {
		// TODO 自动生成方法存根
		String scope = "username=? order by inputtime desc";
		java.util.Collection paras = new java.util.ArrayList();
		paras.add(blog.getUsername());
		DbPageList pList = new DbPageList(VisitInfo.class,scope);
		pList.doList(currentPage,pageSize);
		return pList;
	}

	public boolean addVisitInfo(VisitInfo visitInfo) {
		// TODO 自动生成方法存根
		boolean ret;
		ret = this.dao.save(visitInfo);
		return ret;
	}

	public boolean delVisitInfo(String cid) {
		// TODO 自动生成方法存根
		boolean ret;
		ret = this.dao.del(getVisitInfo(cid));
		return ret;
	}

	public int batchDelVisitInfo(String[] cid) {
		// TODO 自动生成方法存根
		int ret = 0;
		for(int i=0;i<cid.length;i++){
			if(delVisitInfo(cid[i])){
				ret++;
			}
		}
		return ret;
	}

	public VisitInfo getVisitInfo(String cid) {
		// TODO 自动生成方法存根
		return (VisitInfo)this.dao.get(VisitInfo.class,cid);
	}

}
